#include <stdio.h>
#include "./test/test.h"
#include "./log/log.h"
#include "./cutest-1.5/CuTest.h"

//#define LOG_MODULE_LEVEL_ERROR

log_content_t g_tLogger;
char buf[1024];

log_output_desc_t g_tDesc = {
    .pBuffer = buf,
    .wBufferSize = sizeof(buf),
};

int testProc(void)
{
    LOG_DEBUG(&g_tLogger, "this is debug\n");
    LOG_INFO(&g_tLogger, "%s\n", "this is info");
    LOG_WARN(&g_tLogger, "[%s]\n", "this is warn");
    LOG_ERROR(&g_tLogger, "%s, xxxxxx\n", "this is error");
    LOG_CRITICAL(&g_tLogger, "this is critical\n");
}

CuSuite* CuGetSuite();
CuSuite* CuStringGetSuite();

void RunAllTests(void)
{
	CuString *output = CuStringNew();
	CuSuite* suite = CuSuiteNew();

	CuSuiteAddSuite(suite, CuGetSuite());
	CuSuiteAddSuite(suite, CuStringGetSuite());

	CuSuiteRun(suite);
	CuSuiteSummary(suite, output);
	CuSuiteDetails(suite, output);
	printf("%s\n", output->buffer);
}

int main(int argc, char ** argv) {

    printf("----->this is a main program\n");

    test();

    LOG_INIT(&g_tLogger, &g_tDesc, NULL);
    LOG_SET_FORMAT(&g_tLogger,
                    LOG_OPT_FUNCTION_NAME   |
                    LOG_OPT_LINE_NO         |
                    LOG_OPT_DATETIME        |
                    LOG_OPT_LEVEL_NAME);
    
    testProc();

    RunAllTests();

    return 0;
}
